{extend name="admin@index_layout"/}
{block name="main"}
<form class="layui-form" method="post">
    <input name="id" type="hidden" value="{$data.id}">
    <input name="logo_url" type="hidden" value="{$data.logo_url}">

    <input type="hidden" name="old_business_license" value="{$data.business_license}">
    <input type="hidden" name="old_food_business_license" value="{$data.food_business_license}">

    <div class="layui-form-item">
        <label class="layui-form-label">商家名称</label>
        <div class="layui-input-block">
            <input type="text" name="row[business_name]" autocomplete="off" placeholder="商家名称" class="layui-input"
                   value="{$data.business_name}" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商家联系人</label>
        <div class="layui-input-block">
            <input type="text" name="row[name]" autocomplete="off" placeholder="商家联系人" class="layui-input"
                   value="{$data.name}" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系电话</label>
        <div class="layui-input-block">
            <input type="text" name="row[phone]" autocomplete="off" placeholder="联系电话" class="layui-input"
                   value="{$data.phone}" >
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">省</label>
        <div class="layui-input-block">
            <select name="row[province]" lay-verify="required" lay-filter="ccc62">
                <option value="">请选择省</option>
                {volist name="proviec" id="vo"}
                <!--                <option  value="{$key.id}"  name="row[operate_type]">{$key.name}</option>-->
                <option value="{$vo.name}" <?php if( $vo['name'] == $data['province']){ ?> selected <?php }?>>{$vo.name}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">市</label>
        <div class="layui-input-block">
            <select id="c-city" name="row[city]" lay-verify="required" lay-filter="c-city">
                <option value="">请选择市</option>
                {volist name="city_list" id="vo"}
                <option value="{$vo.name}" <?php if( $vo['name'] == $data['city']){ ?> selected <?php }?>>{$vo.name}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">区</label>
        <div class="layui-input-block">
            <select id="c-city2" name="row[area]" lay-verify="required" lay-filter="c-city2">
                <option value="">请选择区</option>
                {volist name="area_list" id="vo"}
                <option value="{$vo.name}" <?php if( $vo['name'] == $data['area']){ ?> selected <?php }?>>{$vo.name}</option>
                {/volist}
            </select>
        </div>
    </div>


<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">省</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="text" name="row[province]" autocomplete="off" placeholder="省" class="layui-input"-->
<!--                   value="{$data.province}" >-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">市</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="text" name="row[city]" autocomplete="off" placeholder="市" class="layui-input"-->
<!--                   value="{$data.city}" >-->
<!--        </div>-->
<!--    </div>-->



<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">区</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="text" name="row[area]" autocomplete="off" placeholder="区" class="layui-input"-->
<!--                   value="{$data.area}">-->
<!--        </div>-->
<!--    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">详情地址</label>
        <div class="layui-input-block">
            <input type="text" name="row[address]" autocomplete="off" placeholder="详情地址:xx路xx号" class="layui-input"
                   value="{$data.address}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">营业执照</label>
        <div class="layui-input-block">
            <div class="w300">
                <input value="{$data.business_license}" type="text" lay-verify="required" name="row[business_license]" id="c-pic22"
                       class="layui-input">
            </div>
            <button type="button" class="layui-btn faupload" id="faupload-pic22" data-multiple="false"
                    data-input-id="c-pic22"
                    data-preview-id="p-pic22" data-type="image"><i class="layui-icon layui-icon-upload"></i> 上传
            </button>
            <button type="button" class="layui-btn fachoose" data-multiple="false" data-mimetype="image"
                    data-input-id="c-pic22" id="fachoose-c-pic22"><i class="iconfont icon-other"></i> 选择
            </button>
            <ul class="layui-row list-inline plupload-preview" id="p-pic22"></ul>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">食品经营许可</label>
        <div class="layui-input-block">
            <div class="w300">
                <input value="{$data.food_business_license}" type="text" lay-verify="required" name="row[food_business_license]" id="c-pic222"
                       class="layui-input">
            </div>
            <button type="button" class="layui-btn faupload" id="faupload-pic222" data-multiple="false"
                    data-input-id="c-pic222"
                    data-preview-id="p-pic222" data-type="image"><i class="layui-icon layui-icon-upload"></i> 上传
            </button>
            <button type="button" class="layui-btn fachoose" data-multiple="false" data-mimetype="image"
                    data-input-id="c-pic222" id="fachoose-c-pic222"><i class="iconfont icon-other"></i> 选择
            </button>
            <ul class="layui-row list-inline plupload-preview" id="p-pic222"></ul>
        </div>
    </div>


<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label" style="width: 220px !important;">营业执照 \ 食品经营许可</label>-->
<!--        <div class="layui-input-block">-->
<!--            <ul class="layui-row list-inline plupload-preview" id="p-pic">-->
<!--                <li class="file-item thumbnail"><a href="javascript:;">-->
<!--                    <img data-image=""-->
<!--                         onerror="this.src='/admin/ajax/icon?suffix=png';this.onerror=null;"-->
<!--                         data-original="{$data.business_license}"-->
<!--                         src="{$data.business_license}">-->
<!--                </a>-->
<!--                </li>-->
<!--                <li class="file-item thumbnail"><a href="javascript:;">-->
<!--                    <img data-image=""-->
<!--                         onerror="this.src='/admin/ajax/icon?suffix=png';this.onerror=null;"-->
<!--                         data-original="{$data.food_business_license}"-->
<!--                         src="{$data.food_business_license}">-->
<!--                </a>-->
<!--                </li>-->
<!--            </ul>-->
<!--        </div>-->
<!--    </div>-->

    <div class="layui-form-item">
        <label class="layui-form-label">商家图标icon：建议90*90</label>
        <div class="layui-input-block">
            <div class="w300">
                <input value="{$data.logo_url}" type="text" lay-verify="required" name="row[logo_url]" id="c-pic2"
                       class="layui-input">
            </div>
            <button type="button" class="layui-btn faupload" id="faupload-pic" data-multiple="false"
                    data-input-id="c-pic2"
                    data-preview-id="p-pic2" data-type="image"><i class="layui-icon layui-icon-upload"></i> 上传
            </button>
            <button type="button" class="layui-btn fachoose" data-multiple="false" data-mimetype="image"
                    data-input-id="c-pic2" id="fachoose-c-pic"><i class="iconfont icon-other"></i> 选择
            </button>
            <ul class="layui-row list-inline plupload-preview" id="p-pic2"></ul>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">商家门头图片：建议1125*702</label>
        <div class="layui-input-block">
            <div class="w300">
                <input value="{$data.business_img}" type="text" lay-verify="required" name="row[business_img]" id="c-pic3"
                       class="layui-input">
            </div>
            <button type="button" class="layui-btn faupload" id="faupload-pic2" data-multiple="false"
                    data-input-id="c-pic3"
                    data-preview-id="p-pic3" data-type="image"><i class="layui-icon layui-icon-upload"></i> 上传
            </button>
            <button type="button" class="layui-btn fachoose" data-multiple="false" data-mimetype="image"
                    data-input-id="c-pic3" id="fachoose-c-pic2"><i class="iconfont icon-other"></i> 选择
            </button>
            <ul class="layui-row list-inline plupload-preview" id="p-pic3"></ul>
        </div>
    </div>

    <div class="layui-form-item c3"  >
        <label class="layui-form-label">提现银行名称</label>
        <div class="layui-input-block">
            <input type="text" name="row[bank_name]" autocomplete="off" placeholder="例：中国银行"
                   class="layui-input"
                   value="{$data.bank_name}">
        </div>
    </div>
    <div class="layui-form-item c3"  >
        <label class="layui-form-label">银行开户名</label>
        <div class="layui-input-block">
            <input type="text" name="row[bank_account_name]" autocomplete="off" placeholder="银行开户名"
                   class="layui-input"
                   value="{$data.bank_account_name}">
        </div>
    </div>
    <div class="layui-form-item c3"  >
        <label class="layui-form-label">银行账号</label>
        <div class="layui-input-block">
            <input type="text" name="row[bank_account]" autocomplete="off" placeholder="银行账号"
                   class="layui-input"
                   value="{$data.bank_account}">
        </div>
    </div>
    <div class="layui-form-item c3">
        <label class="layui-form-label">财务联系人</label>
        <div class="layui-input-block">
            <input type="text" name="row[finance_people]" autocomplete="off" placeholder="财务联系人"
                   class="layui-input"
                   value="{$data.finance_people}">
        </div>
    </div>
    <div class="layui-form-item c3">
        <label class="layui-form-label">财务联系电话</label>
        <div class="layui-input-block">
            <input type="text" name="row[finance_phone]" autocomplete="off" placeholder="财务联系电话"
                   class="layui-input"
                   value="{$data.finance_phone}">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">提现手续费（正数百分比）</label>
        <div class="layui-input-block">
            <input type="number" name="row[commission]" autocomplete="off" placeholder="手续费 100% 单位整数"
                   class="layui-input"
                   value="{$data.commission}">
        </div>
    </div>

    <div class="layui-form-item c32">
        <label class="layui-form-label">余额到账天数</label>
        <div class="layui-input-block">
            <input type="number" name="row[to_day]" autocomplete="off" placeholder="核销后到账余额天数"
                   class="layui-input"
                   value="{$data.to_day}">
        </div>
    </div>

    <div class="layui-form-item c33">
        <label class="layui-form-label">最低提现营业额</label>
        <div class="layui-input-block">
            <input type="number" name="row[min_tixian]" autocomplete="off" placeholder="最低提现营业额"
                   class="layui-input"
                   value="{$data.min_tixian}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">经营方式</label>
        <div class="layui-input-block">
            <select name="row[operate_type]" lay-verify="required" lay-filter="ccc6">
                <option value="">请选择经营方式</option>
                {if !empty($operate_type_list)}
                {foreach $operate_type_list as $key}
                <option <?php if( $key['id'] == $data['operate_type']){ ?> selected <?php }?> value="{$key.id}"  name="row[operate_type]">{$key.name}</option>
                {/foreach}
                {/if}
            </select>
        </div>
    </div>

    <div class="layui-form-item c5" {if $data.operate_type!=3}style="display: none;"{/if}>
        <label class="layui-form-label">品牌名称(连锁品牌需要选择)</label>
        <div class="layui-input-block">
            <select name="row[brand]">
                <option value="">请选择品牌名称</option>
                {if !empty($brand_list)}
                {foreach $brand_list as $key}
                <option <?php if( $key['id'] == $data['brand']){ ?> selected <?php }?> value="{$key.id}"  name="row[brand]">{$key.name}</option>
                {/foreach}
                {/if}
            </select>
        </div>
    </div>


    <div class="layui-form-item layer-footer">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit>提交</button>
        </div>
    </div>
</form>
{/block}
{block name="script"}
<script type="text/javascript">
    layui.use(['yznForm', 'laydate','form'], function () {
        var yznForm = layui.yznForm,
            laydate = layui.laydate;
        var form = layui.form;
        yznForm.bindevent($("form.layui-form"));
        laydate.render({
            elem: '#ID-laydate'
        });
        form.on('select(ccc6)', function (data) {
            console.log(data.value);
            if (data.value == 3) {
                $(".c5").show();
            } else{
                $(".c5").hide();
            }
            form.render();
        });

        form.on('select(ccc62)', function (data) {
            console.log(data.value);
            $.ajax({
                type: "POST",//规定传输方式
                url: "{:url('getc_cate')}",//提交URL
                data: {'id': data.value},//提交的数据
                success: function (result) {
                    if (result.code == 200) {
                        $("#c-city").empty();
                        var str = "<option value>请选择市</option>";
                        $.each(result.data, function (i, val) {
                            str += '<option value=' + val.name + '>' + val.name + '</option>'
                        });
                        $("#c-city").append(str);

                        $("#c-city2").empty();
                        var str2 = "<option value>请选择区</option>";
                        $("#c-city2").append(str2);

                        layui.form.render('select');
                    }
                },
                error: function () {
                    alert("获取信息失败")
                }
            });
            form.render();
        });

        form.on('select(c-city)', function (data) {
            $.ajax({
                type: "POST",//规定传输方式
                url: "{:url('getc_cate')}",//提交URL
                data: {'id': data.value},//提交的数据
                success: function (result) {
                    if (result.code == 200) {

                        $("#c-city2").empty();
                        var str = "<option value>请选择区</option>";
                        $.each(result.data, function (i, val) {
                            str += '<option value=' + val.name + '>' + val.name + '</option>'
                        });
                        $("#c-city2").append(str);
                        layui.form.render('select');
                    }
                },
                error: function () {
                    alert("获取信息失败")
                }
            });
            form.render();
        });

    });
</script>
{/block}